﻿using IterationLife.Domains.Sports.Models;
using Util;
using Util.Maps;

namespace IterationLife.Football.MTSports.Dtos.Sports {
    /// <summary>
    /// 体育比赛分组个人分段数据传输对象扩展
    /// </summary>
    public static class SportEventGroupPersonSectionDtoExtension {
        /// <summary>
        /// 转换为体育比赛分组个人分段实体
        /// </summary>
        /// <param name="dto">体育比赛分组个人分段数据传输对象</param>
        public static SportEventGroupPersonSection ToEntity( this SportEventGroupPersonSectionDto dto ) {
            if ( dto == null )
                return new SportEventGroupPersonSection();
            return dto.MapTo( new SportEventGroupPersonSection( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为体育比赛分组个人分段实体
        /// </summary>
        /// <param name="dto">体育比赛分组个人分段数据传输对象</param>
        public static SportEventGroupPersonSection ToEntity2( this SportEventGroupPersonSectionDto dto ) {
            if( dto == null )
                return new SportEventGroupPersonSection();
            return new SportEventGroupPersonSection( dto.Id.ToGuid() ) {
                SportEventGroupSectionId = dto.SportEventGroupSectionId,
                SportAthleteId = dto.SportAthleteId,
                StartTime = dto.StartTime,
                EndTime = dto.EndTime,
                JsonData = dto.JsonData,
                CreationTime = dto.CreationTime,
                CreatorId = dto.CreatorId,
                LastModificationTime = dto.LastModificationTime,
                LastModifierId = dto.LastModifierId,
                IsDeleted = dto.IsDeleted,
                Version = dto.Version,
            };
        }
        
        /// <summary>
        /// 转换为体育比赛分组个人分段数据传输对象
        /// </summary>
        /// <param name="entity">体育比赛分组个人分段实体</param>
        public static SportEventGroupPersonSectionDto ToDto(this SportEventGroupPersonSection entity) {
            if( entity == null )
                return new SportEventGroupPersonSectionDto();
            return entity.MapTo(new SportEventGroupPersonSectionDto());
        }

        /// <summary>
        /// 转换为体育比赛分组个人分段数据传输对象
        /// </summary>
        /// <param name="entity">体育比赛分组个人分段实体</param>
        public static SportEventGroupPersonSectionDto ToDto2( this SportEventGroupPersonSection entity ) {
            if( entity == null )
                return new SportEventGroupPersonSectionDto();
            return new SportEventGroupPersonSectionDto {
                Id = entity.Id.ToString(),
                SportEventGroupSectionId = entity.SportEventGroupSectionId,
                SportAthleteId = entity.SportAthleteId,
                StartTime = entity.StartTime,
                EndTime = entity.EndTime,
                JsonData = entity.JsonData,
                CreationTime = entity.CreationTime,
                CreatorId = entity.CreatorId,
                LastModificationTime = entity.LastModificationTime,
                LastModifierId = entity.LastModifierId,
                IsDeleted = entity.IsDeleted,
                Version = entity.Version,
            };
        }
    }
}
